package com.ff.discounts.component.sale

import androidx.recyclerview.widget.GridLayoutManager
import com.ff.discounts.R
import com.ff.discounts.activity.BaseViewModelActivity
import com.ff.discounts.component.saleorder.SaleOrderActivity
import com.ff.discounts.component.tab.home.HistoryData
import com.ff.discounts.databinding.ActivitySpecialSaleBinding
import com.ff.discounts.superui.decoration.GridDividerItemDecoration
import com.ff.discounts.superui.util.DensityUtil
import com.qmuiteam.qmui.util.QMUIStatusBarHelper

/**
 *19 天天特卖
 * @author: fufang
 * @date: 2023/11/2
 */
class SpecialSaleActivity : BaseViewModelActivity<ActivitySpecialSaleBinding>() {
    private lateinit var adapter: SaleGoodsAdapter

    override fun initListeners() {
        super.initListeners()

        binding.back.setOnClickListener {
            finish()
        }
        binding.goOrder.setOnClickListener {
            startActivity(SaleOrderActivity::class.java)
        }
    }

    override fun initViews() {
        super.initViews()

        // 设置沉浸式状态栏
        QMUIStatusBarHelper.translucent(this)
        //  // 热门推荐适配器
        adapter = SaleGoodsAdapter()
        binding.saleList.adapter = adapter
        val itemDecoration = GridDividerItemDecoration(
            binding.saleList.context,
            DensityUtil.dip2px(binding.saleList.context, 5f).toInt()
        )
        binding.saleList.apply {
            layoutManager = GridLayoutManager(hostActivity,2)
            addItemDecoration(itemDecoration)
        }
        adapter.submitList(SpecialSaleActivity.historyDataList)
    }

    override fun initDatum() {
        super.initDatum()
    }

    companion object{
        private val historyDataList = mutableListOf<HistoryData>(
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集"),
            HistoryData(R.drawable.photo,"极品校花爱上我", "第五集")
        )
    }
}